package com.chuangke.apim.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chuangke.admin.data.builder.DictDataBuilder;
import com.chuangke.admin.data.builder.UserDataBuilder;
import com.chuangke.apim.dao.SysApiDocumentDao;
import com.chuangke.apim.entity.SysApiDocument;
import com.chuangke.common.constant.SysDictTypeConstants;
import com.chuangke.common.data.builder.DataBuildConfig;
import com.chuangke.common.data.builder.DataBuilder;
import com.chuangke.common.db.page.CkPageQuery;
import com.chuangke.framework.service.impl.GridDictModelServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class SysApiDocumentService extends GridDictModelServiceImpl<SysApiDocumentDao, SysApiDocument> {

	@Override
	public IPage<SysApiDocument> page(CkPageQuery page) {
		IPage<SysApiDocument> result = super.page(page);
//		result.setRecords(result.getRecords().stream().sorted(Comparator.comparing(SysApiApp::getActionType).thenComparing(QhseAction::getId)).toList() );
		DataBuilder.of(result.getRecords())
				.appendBuilder(new UserDataBuilder(), new DataBuildConfig("createdBy", "createdByName"),
						new DataBuildConfig("updatedBy", "updatedByName"))
				.appendBuilder(new DictDataBuilder(SysDictTypeConstants.QHSE_ACTION_TYPE),
						new DataBuildConfig("actionType", "actionTypeName"))
				.build();

		return result;
	}

}
